Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
Often, programmers fall in love with Python because of the increased productivity it provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception. When the program doesn't catch the exception, the interpreter prints a stack trace. A source level debugger allows inspection of local and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's introspective power. On the other hand, often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective. (http://www.python.org/doc/essays/blurb.html)
Python was conceived in the late 1980s[20] and its implementation was started in December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to the ABC language (itself inspired by SETL) capable of exception handling and interfacing with the Amoeba operating system.[2] Van Rossum is Python's principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community, Benevolent Dictator for Life (BDFL). Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for Unicode. With this release the development process was changed and became more transparent and community-backed. Python 3.0 (also called Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008 after a long period of testing. Many of its major features have been backported to the backwards-compatible Python 2.6 and 2.7. http://en.wikipedia.org/wiki/Python_(programming_language)
Guido van Rossum (born 31 January 1956) is a Dutch computer programmer who is best known as the author of the Python programming language. In the Python community, Van Rossum is known as a "Benevolent Dictator For Life" (BDFL), meaning that he continues to oversee the Python development process, making decisions where necessary. He was employed by Google from 2005 until December 7th 2012, where he spent half his time developing the Python language. In January 2013, Van Rossum started working for Dropbox. (http://en.wikipedia.org/wiki/Guido_van_Rossum)
Python's name is derived from the television series Monty Python's Flying Circus and it is common to use Monty Python references in example code. For example, the metasyntactic variables often used in Python literature are spam and eggs, instead of the traditional foo and bar.
For many, Python’s focus on readability, coherence, and software quality in general sets it apart from other tools in the scripting world. Python code is designed to be readable, and hence reusable and maintainable—much more so than traditional scripting languages. The uniformity of Python code makes it easy to understand, even if you did not write it. In addition, Python has deep support for more advanced software reuse mechanisms, such as object-oriented (OO) and function programming.
Python boosts developer productivity many times beyond compiled or statically typed languages such as C, C++, and Java. Python code is typically one-third to one-fifth the size of equivalent C++ or Java code. That means there is less to type, less to debug, and less to maintain after the fact. Python programs also run immediately, without the lengthy compile and link steps required by some other tools, further boosting programmer speed.
Most Python programs run unchanged on all major computer platforms. Porting Python code between Linux and Windows, for example, is usually just a matter of copying a script’s code between machines. Moreover, Python offers multiple options for coding portable graphical user interfaces, database access programs,web-based systems, and more. Even operating system interfaces, including program launches and directory processing, are as portable in Python as they can possibly be. pport libraries
Python comes with a large collection of prebuilt and portable functionality, known as the standard library. This library supports an array of application-level programming tasks, from text pattern matching to network scripting. In addition, Python can be extended with both homegrown libraries and a vast collection of third-party application support software. Python’s third-party domain offers tools for website construction, numeric programming, serial port access, game development, and much more (see ahead for a sampling). The NumPy extension, for instance, has been described as a free and more powerful equivalent to the Matlab numeric programming system.
Python scripts can easily communicate with other parts of an application, using a variety of integration mechanisms. Such integrations allow Python to be used as a product customization and extension tool. Today, Python code can invoke C and C++ libraries, can be called from C and C++ programs, can integrate with Java and .NET components, can communicate over frameworks such as COM and Silverlight, can interface with devices over serial ports, and can interact over networks with interfaces like SOAP, XML-RPC, and CORBA. It is not a standalone tool.
Because of Python’s ease of use and built-in toolset, it can make the act of programming more pleasure than chore. Although this may be an intangible benefit, its effect on productivity is an important asset.
This is copied from your textbook
We'll standarize the code for this class. Making the coding style uniform makes it easy for the code to be used in different IDEs and other editors across multiple platforms and operating systems. Here are the basic rules:
In general, use names that are descriptive. Longer names are preferred for clarity. That comes in handy when you revisit your code months even years from the time it was written.
You're discouraged from using global variables but if you feel the need to use them then they should all be capital letters with underscores between the words. Try not to abbreviate words. Example:
SENSOR_ROWS = 6
User-defined classes variables start with a capital letter for each word, no underscore between words. Example:
Projectdata, CameraModel, Sensor
A function's name needs to represent an action (think verb): get, set, truncate, etc... The first word is all lower case letters and subsequent words (if any) start with upper case letters without an underscore between them. Example:
getHeader, truncate, getAverageAndError, setLimits
All lower case, undescores between words. Words may be abbreviated if necessary.
Example: Let's say we're assigning the name of a camera calibration file, here is how I would define a variable to hold the name: camera_calib_file_name
Refrain from using one or two letter variable names unless they're used as dummy variables in a short segment of the code. For example, if I am looping though a list of fine names, then the iteration variable should be file_name instead of f:
Formatting is very important in Python. Indentation not only makes the code clearer to read but it is part of the language: logical blocks, like loops and functions, use indentation to for beginning and ending markers. There are two ways to indent block, tabs and spaces. You need to set your favorite editor to use spaces for indentation as opposed to tabs and sent the width to 3 spaces.
There are many editors avialble for use to program in Python. They offer syntax highlighting, indentation markers, and some offer inline debigging and project management.
In [ ]:
In [1]:
from IPython.core.display import HTML
def css_styling():
styles = open("styles/custom.css", "r").read()
return HTML(styles)
css_styling()
Out[1]:
In [ ]: